home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
sound
/
sound.frm
< prev
next >
Wrap
Text File
|
1994-10-21
|
2KB
|
101 lines
VERSION 2.00
Begin Form Form1
Caption = "Form1"
ClientHeight = 2550
ClientLeft = 3690
ClientTop = 2370
ClientWidth = 2370
Height = 2955
Left = 3630
LinkTopic = "Form1"
ScaleHeight = 2550
ScaleWidth = 2370
Top = 2025
Width = 2490
Begin CommandButton Command3
Caption = "Stop Sound/Siren"
Height = 615
Left = 240
TabIndex = 2
Top = 1680
Width = 1815
End
Begin CommandButton Command2
Caption = "Play Siren"
Height = 615
Left = 240
TabIndex = 1
Top = 840
Width = 1815
End
Begin CommandButton Command1
Caption = "Play Sound"
Height = 615
Left = 240
TabIndex = 0
Top = 120
Width = 1815
End
End
Option Explicit
DefInt A-Z
Dim SoundStat%
Sub Command1_Click ()
PlaySounds
End Sub
Sub Command2_Click ()
PlaySiren
End Sub
Sub Command3_Click ()
Dim x%
If SoundStat% <> 0 Then
x% = StopSound()
CloseSound
SoundStat% = 0
End If
End Sub
Sub PlaySiren ()
Dim SoundVal&, Freq%, Duration%, OffSet%, x%
If SoundStat% = 0 Then SoundStat% = OpenSound%()
x% = SetVoiceQueueSize(1, 1000)
x% = SetVoiceAccent(1, 120, 255, 1, 0)
Freq% = 800
Duration% = 10
OffSet% = 5
Do
SoundVal& = CLng(Freq%) * &H1000
x% = SetVoiceSound%(1, SoundVal&, Duration%)
Freq% = Freq% + OffSet%
If Freq% >= 1000 Then OffSet% = -5
If Freq% <= 800 Then OffSet% = 5
Loop While x% = 0
x% = StartSound%()
End Sub
Sub PlaySounds ()
Dim Note%, Duration%, x%
If SoundStat% = 0 Then SoundStat% = OpenSound%()
x% = SetVoiceQueueSize(1, 1024)
Do
Note% = Int(Rnd * 84 + 1)
Duration% = 2 ^ Int(Rnd * 4)
x% = SetVoiceNote%(1, Note%, Duration%, 1)
Loop While x% = 0
x% = StartSound%()
End Sub